import { createRouter, createWebHistory } from 'vue-router'

// createRouter创建路由的实例
// 配置 history和hash
// 1.history模式  createWebHistory  地址栏不带#
// 2.hash 模式 createWebHashHistory 地址栏带#

// vite 中的环境变量import.meta.env.BASE_URL
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),  // 路径前缀
  routes: [
    {
      path: '/login',
      name: 'login',
      component: () => import('@/views/login/loginPage.vue')
    },
    {
      path: '/home',
      name: 'home',
      component: () => import('@/views/home/homeView.vue')
    },
    {
      path: '/pinia',
      name: 'pinia',
      component: () => import('@/views/pinia/piniaIndex.vue')
    },
    {
      path: '/',
      name: 'layout',
      component: () => import('@/views/layout/layoutContainer.vue'),
      redirect:'/goods/list',
      children: [
        {
          path: '/goods/list',
          name: 'list',
          component: () => import( '@/views/goods/goodsList.vue')
        },
        {
          path: '/goods/detail',
          name: 'detail',
          component: () => import('@/views/goods/goodsDetail.vue')
        },

        {
          path: '/user/password',
          name: 'password',
          component: () => import('@/views/user/userPassword.vue')
        },
        {
          path: '/user/avatar',
          name: 'userAvatar',
          component: () => import('@/views/user/userAvatar.vue')
        },
        {
          path: '/user/list',
          name: 'userlist',
          component: () => import('@/views/user/userList.vue')
        }
      ]
    },
  ]
})

export default router
